#ifndef __HOOK_LOG_H_
#define __HOOK_LOG_H_

void JoySaveLog(const char* path, const char* logText)
{
    if(path == NULL || logText == NULL)
    {
        return;
    }

  
    SYSTEMTIME t;
    GetLocalTime(&t);    

	FILE* f = fopen(path, "a");
    if(f == NULL)
    {
      return;
    }
    if(f != NULL)
    {
        fprintf(f, "[%.4d-%.2d-%.2d %.2d:%.2d:%.2d]",
            t.wYear, t.wMonth, t.wDay, t.wHour, t.wMinute, t.wSecond);
	    fprintf(f, logText);
		fprintf(f, "\n");
	    fclose(f);
    }
}
void DbPrint(const char* logText)
{
	JoySaveLog("d:\\log.txt",logText);
}
void debugInetAddr(sockaddr_in *addr)
{
	char sTemp[100];
	char sip[20];
	sprintf(sip,inet_ntoa(addr->sin_addr));
	//sprintf(sip,"%d.%d.%d.%d",addr->sin_addr.S_un.S_un_b.s_b1,addr->sin_addr.S_un.S_un_b.s_b2,addr->sin_addr.S_un.S_un_b.s_b3,addr->sin_addr.S_un.S_un_b.s_b4);
	sprintf(sTemp,"IP:%s port:%d",sip,ntohs(addr->sin_port));
    DbPrint(sTemp);
}
void debugIPXAddr(sockaddr_ipx *addr)
{
	char sTemp[100];
	sprintf(sTemp,"netnum:%s,nodenum:%s,port:%d",addr->sa_netnum,addr->sa_nodenum,ntohs(addr->sa_socket));
    DbPrint(sTemp);

}
#endif//__HOOK_LOG_H_
